<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<ui:composition xmlns="http://www.w3.org/1999/xhtml" 
                xmlns:h="http://java.sun.com/jsf/html" 
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:a4j="http://richfaces.org/a4j"
                xmlns:rich="http://richfaces.org/rich"
                template="/restrito/layout/template.xhtml" >

    <ui:define name="content">
        <f:view>
            <h:form>
                
                <h:panelGrid id="grid" columns="2">  
                    
                    <h:outputLabel value="Descrição:"/>
                    <h:inputText value="#{produtoController.produto.descricao}"/>          
                    
                    <h:outputLabel value="Valor:"/>
                    <h:inputText value="#{produtoController.produto.valor}"/>                           
                    
                </h:panelGrid>    
                <h:panelGrid columns="2" columnClasses="top,top">
                    
                    <rich:fileUpload fileUploadListener="#{produtoController.listener}"
                            id="upload" acceptedTypes="jpg, gif, png, bmp">
                            <a4j:ajax event="uploadcomplete" execute="@none" render="info" />
                        </rich:fileUpload>
                    <h:panelGroup id="info" layout="block">

                        <rich:panel bodyClass="info">
                            <f:facet name="header">
                                <h:outputText value="Uploaded Files Info" />
                            </f:facet>
                       
                         <h:outputText value="No files currently uploaded"
                                rendered="#{produtoController.size==0}" />
                         
                            <rich:dataGrid columns="1" value="#{produtoController.files}"
                                        var="file" rowKeyVar="row">
                                <rich:panel bodyClass="rich-laguna-panel-no-header">
                                    <h:panelGrid columns="2">
                                       
                                        <a4j:mediaOutput element="img" mimeType="image/jpeg"
                                            createContent="#{produtoController.paint}" value="#{row}"
                                            style="width:100px; height:100px;" cacheable="false">
                                            <f:param value="#{produtoController.timeStamp}" name="time" />
                                        </a4j:mediaOutput>
                                        <h:panelGrid columns="2">
                                            <h:outputText value="File Name:" />
                                            <h:outputText value="#{file.name}" />
                                            <h:outputText value="File Length(bytes):" />
                                            <h:outputText value="#{file.length}" />
                                        </h:panelGrid>                                     
                                     </h:panelGrid>
                                 </rich:panel>
                            </rich:dataGrid>
                         </rich:panel>
                            <br />
                         <a4j:commandButton action="#{produtoController.clearUploadData}"
                                render="info, upload" value="Clear Uploaded Data"
                                rendered="#{produtoController.size>0}" />
                         
                    </h:panelGroup>                    
                 </h:panelGrid>
                <h:panelGrid>
                    <a4j:commandButton action="#{produtoController.inserir()}" value="Salvar" 
                                            onclick= "javaScript:return(confirm('Desseja cadastrar?'))"/>          
                </h:panelGrid>
                
            </h:form>
        </f:view>
    </ui:define>
</ui:composition>
